package com.trade.tradebusiness.service.impl;

import com.trade.core.message.TradeObjectRestResponse;
import com.trade.core.trade.TradeBuild;
import com.trade.tradebusiness.constant.OrderTradeStepStatement;
import com.trade.tradebusiness.entity.dto.CreateOrderDTO;
import com.trade.tradebusiness.entity.vo.TradeCreateOrderAfterVO;
import com.trade.tradebusiness.service.OrderService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author sven.wang
 * @version 2022/1/6 14:54
 * @Description:
 */
@Service
public class OrderServiceImpl implements OrderService {
    @Resource
    private TradeBuild tradeBuild;

    @Override
    public TradeObjectRestResponse<String> create(CreateOrderDTO dto) {
        TradeCreateOrderAfterVO orderAfter = (TradeCreateOrderAfterVO) tradeBuild.processTradeBySteps(OrderTradeStepStatement.createOrder,
                OrderTradeStepStatement.createOrderName, dto).checkAndGetData();
        return TradeObjectRestResponse.success(orderAfter.getOrderId());
    }
}
